package public

import (
	"fmt"
	"log"

	"github.com/huichen/gobo"
)

var (
	weibo = gobo.Weibo{}
)

// WeiboDailyThinking is WeiboDailyThinking
func WeiboDailyThinking(pmsg string) {

	content := pmsg

	content += " 每周总结：https://github.com/wangcy6/weekly,每日复盘:https://wangcy6.github.io"
	if len(content) > 140 {
		return
	}
	weiboBlogDaily(content)

}

// dialyWeibo is dialyWeibo
func dialyWeibo() {
	msg := getDayOfyear()
	fmt.Println(msg)
	weiboBlogDaily(msg)
}

// weiboBlogDaily weiboBlogDaily
func weiboBlogDaily(content string) {
	params := gobo.Params{"source": "1039830970", "status": "#golang# " + content}
	if err := weibo.Call("statuses/share", "post", "2.00GocTFCQXB4IB5fbed9175d_9VviD", params, nil); err != nil {
		log.Printf("[ERROR] PostWeibo: %s\n", err)
	}
}
